CC=gcc
CFLAGS+=-Wall
LIBPATH=../..
INCLS=-I$(LIBPATH)/include
OS=$(shell uname)

ifeq ($(LIBTYPE), debug)
    CFLAGS+=-g
    LIB=libsoar_g
endif
ifeq ($(LIBTYPE), release)
    CFLAGS+=-O3
    LIB=libsoar
endif

OBJS=errlog.o svcnode.o

#option=$(shell if test ! -z "$$ORACLE_HOME" -a -d "$$ORACLE_HOME"; then echo Y; else echo N; fi)
#ifeq ($(option), Y)
#    OBJS+=oracle.o
#endif

#option=$(shell if test -d /usr/local/mysql/include; then echo CUSTOM; elif test -d /usr/include/mysql; then echo SYSTEM; else echo NO; fi)
#ifeq ($(option), CUSTOM)
#    OBJS+=mysql.o
#endif
#ifeq ($(option), SYSTEM)
#    OBJS+=mysql.o
#endif

#option=$(shell if test -d /usr/local/pgsql/include; then echo CUSTOM; elif test -d /usr/include/pgsql; then echo SYSTEM; else echo NO; fi)
#ifeq ($(option), CUSTOM)
#    OBJS+=pgsql.o
#endif
#ifeq ($(option), SYSTEM)
#    OBJS+=pgsql.o
#endif

.PHONY : all

all : $(OBJS)
	ar -crl ../../lib/$(LIB).a $?
	chmod 644 ../../lib/$(LIB).a

%.o : %.c
	$(CC) $(CFLAGS) $(INCLS) -c -o $@ $<
